package com.qf.day03.HomeWork;

import java.util.Scanner;

public class HomeWork2 {
    public static void main(String[] args) {
       num(1);


    }
    public static void num(int num){
        if (num % 2 != 0 || num <= 2) {
            System.out.println("输入错误，请输入一个大于2的偶数！");
            return;
        }

        boolean isGoldbach = false;
        for (int i = 2; i <= num / 2; i++) {
            if (isPrime(i) && isPrime(num - i)) {
                System.out.println(num + " = " + i + " + " + (num - i));
                isGoldbach = true;
            }
        }

        if (!isGoldbach) {
            System.out.println("无法找到两个质数使得它们的和等于" + num);
        }
    }
    // 判断一个数是否为质数
    public static boolean isPrime(int num) {
        if (num < 2) {
            return false;
        }

        for (int i = 2; i <= Math.sqrt(num); i++) {
            if (num % i == 0) {
                return false;
            }
        }

        return true;
    }
    }

